import express, { Router } from 'express';
import { FileController } from '../controllers/FileController';
import { authMiddleware } from '../middleware/auth';
import { uploadMiddleware, handleMulterError } from '../middleware/upload';

const router: Router = express.Router();
const fileController = new FileController();

// 上传文件 (需要认证)
router.post('/upload', authMiddleware, uploadMiddleware.single('file'), handleMulterError, fileController.upload);

// 批量上传文件 (需要认证)
router.post('/upload-multiple', authMiddleware, uploadMiddleware.array('files', 10), handleMulterError, fileController.uploadMultiple);

// 下载文件
router.get('/download/:id', fileController.download);

// 删除文件 (需要认证)
router.delete('/:id', authMiddleware, fileController.delete);

// 文件预览
router.get('/preview/:id', fileController.preview);

// 获取文件列表
router.get('/', fileController.getFiles);

export default router;